function UpdateAllItems()
	for containerIndex = 1, 15 do
		local bagFrame = getglobal("ContainerFrame"..containerIndex);
		if (bagFrame) then
			local bagIndex = bagFrame:GetID();
			if (bagFrame:IsVisible()) then
				for itemIndex = 1, GetContainerNumSlots(containerIndex - 1) do
					local BoEFontString = getglobal(bagFrame:GetName() .. "Item" .. itemIndex .. "BoEText");
					if(not BoEFontString) then
						local itemButton = getglobal(bagFrame:GetName() .. "Item" .. itemIndex);
						itemButton:CreateFontString(bagFrame:GetName() .. "Item" .. itemIndex .. "BoEText", "OVERLAY");
						BoEFontString = getglobal(bagFrame:GetName() .. "Item" .. itemIndex .. "BoEText");
						BoEFontString:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE");
						BoEFontString:SetPoint("BOTTOMRIGHT", itemButton, "BOTTOMRIGHT", -3, 3);
						BoEFontString:SetTextColor(.3, 1, .3);
					end
					BoEFontString:SetText("");
					MyScanningTooltip:ClearLines();
					MyScanningTooltip:SetBagItem(containerIndex - 1, GetContainerNumSlots(containerIndex - 1) - itemIndex + 1);
					for i=1,MyScanningTooltip:NumLines() do
						local lineText = getglobal("MyScanningTooltipTextLeft" .. i):GetText();
						if (lineText:find(ITEM_BIND_ON_EQUIP, 1, true)) then
							BoEFontString:SetText("BoE");
							break;
						end
					end
				end
			end
		end
	end
	
-- Commented all of this out since GameTooltip:SetBagItem() doesn't appear to work for the bank (BagID -1) anyway.
--	local bankFrame = getglobal("BankFrame");
--	if(bankFrame:IsVisible()) then
--		for bankIndex = 1, GetContainerNumSlots(-1) do
--			local BoEFontString = getglobal("BankFrameItem" .. bankIndex .. "BoEText");
--			if(not BoEFontString) then
--				local itemButton = getglobal("BankFrameItem" .. bankIndex);
--				itemButton:CreateFontString("BankFrameItem" .. bankIndex .. "BoEText", "OVERLAY");
--				BoEFontString = getglobal("BankFrameItem" .. bankIndex .. "BoEText");
--				BoEFontString:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE");
--				BoEFontString:SetPoint("BOTTOMRIGHT", itemButton, "BOTTOMRIGHT", -3, 3);
--				BoEFontString:SetTextColor(.3, 1, .3);
--			end
--			BoEFontString:SetText("");
--			MyScanningTooltip:ClearLines();
--			MyScanningTooltip:SetBagItem(BANK_CONTAINER, GetContainerNumSlots(BANK_CONTAINER) - bankIndex + 1);
--			for i=1,MyScanningTooltip:NumLines() do
--				local lineText = getglobal("MyScanningTooltipTextLeft" .. i):GetText();
--				if (lineText:find(ITEM_BIND_ON_EQUIP, 1, true)) then
--					BoEFontString:SetText("BoE");
--					break;
--				end
--			end
--		end
--	end
end

CreateFrame( "GameTooltip", "MyScanningTooltip" );
MyScanningTooltip:SetOwner( WorldFrame, "ANCHOR_NONE" );
MyScanningTooltip:AddFontStrings(
    MyScanningTooltip:CreateFontString( "$parentTextLeft1", nil, "GameTooltipText" ),
    MyScanningTooltip:CreateFontString( "$parentTextRight1", nil, "GameTooltipText" ) );

local BindingTheoryFrame = CreateFrame("FRAME", "BindingTheoryFrame");
BindingTheoryFrame:RegisterEvent("BAG_UPDATE");
BindingTheoryFrame:RegisterEvent("PLAYERBANKSLOTS_CHANGED");
BindingTheoryFrame:RegisterEvent("PLAYERBANKBAGSLOTS_CHANGED");
BindingTheoryFrame:SetScript("OnEvent", UpdateAllItems);
hooksecurefunc("ContainerFrame_OnShow", UpdateAllItems);
hooksecurefunc("BankFrame_OnShow", UpdateAllItems);